package com.bite.forum.controller;


import com.bite.forum.common.AppResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

/**
 * 127.0.0.1:58080/
 * 网址：http://127.0.0.1:58080/swagger-ui/index.html
 */

@Api(tags = "测试类相关接口")
@RestController
@RequestMapping("/test")
public class TestController {

    @ApiOperation("测试接口1，显示你好")
    @GetMapping("/hello")
    public String hello(){
        return "hello";
    }

    @ApiOperation("测试接口4，按传入姓名显示你好信息")
    @PostMapping("/helloByName")
    public AppResult helloByName (@ApiParam("姓名")  @RequestParam("name") String name){
        return AppResult.success("hello:"+name);
    }

    @ApiOperation("测试接口2，显示抛出的异常信息")
    @GetMapping("/exception")
    public AppResult testException () throws Exception{
        throw new Exception("这是一个Exception...");
    }


    @ApiOperation("测试接口3，显示抛出的自定义的异常信息")
    @GetMapping("/appException")
    public AppResult testapplicationException () throws Exception{
        throw new Exception("这是一个ApplicationException...");
    }
}
